const fs = require('fs')
const path = require('path')

// 生成write Stream
function createWriteStream(fileName) {
  const filePath = path.join(__dirname, '../', '../', 'logs', fileName)
  const writeStream = fs.createWriteStream(filePath, {
    flags: 'a' // 追加写入
  })
  return writeStream
}

// 写访问日志
const accessWriteStream = createWriteStream('access.log')
function accessLog(log) {
  accessWriteStream.write(log + '\n')
}

module.exports = {
  accessLog
}